package cn.xi.service.imp;

import cn.xi.dao.StudentDao;
import cn.xi.domain.Student;
import cn.xi.service.StudentService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;

@Service
public class StudentServiceIpml implements StudentService {
@Autowired
    private StudentDao studentDao;

    @Override
    public List<Student> findAll() {
        return studentDao.findAll();
    }

    @Override
    public Student findById(String name) {
        return studentDao.findById(name);
    }

    @Override
    public int save(Student student) {
        int save = studentDao.save(student);
        return save;
    }

    @Override
    public int update(Student student) {
        return studentDao.update(student);
    }

    @Override
    public int delete(String name) {
        return studentDao.delete(name);
    }

//    实现分页查询
    public PageInfo findpage(Integer page,Integer size) {
        PageHelper.startPage(page,size);
        List<Student> all = studentDao.findAll();
        PageInfo pageInfo =new PageInfo(all);
        return pageInfo;
    }
}
